<?php

// should xajax be called?
$xajaxGo = false;

// sve: Start Xajax
include_once(LIBS_DIR.'xajax/xajax.inc.php');

switch ($action) {
	case 'manageEmailNotifications':
		include_once('xajax/manageEmailNotifications.php');
		$xajaxGo = true;
	break;
	case 'manageDomains':
		include_once(LIBS_DIR.'Error/Error.class.php');
		include_once(LIBS_DIR.'Products/Product.class.php');
		include_once(LIBS_DIR.'Products/ResellerProducts.class.php');
		include_once(LIBS_DIR.'Products/Price.class.php');
		include_once(LIBS_DIR.'Currencies/Currencies.class.php');

		$dns_products = new ResellerProducts($master_db, 12, 'USD', "WHERE type in('dns_package', 'res_regdomain')");
		
		foreach($dns_products->product as $k=>$v){
			if($v->type == 'res_regdomain'){
				$rp_products['p3'] = $k;
			}elseif($v->name == 'Private DNS1'){
				$rp_products['p1'] = $k;
			}elseif($v->name == 'Private DNS2'){
				$rp_products['p2'] = $k;
			}
		}

		$ns_types = array(
			'ns1' => 'ns',
			'ns2' => 'dns'
		);
		
		$fileTemplate = 'domain/domain.html';
		include_once('xajax/manageDomains.php');
		$xajaxGo = true;
	break;
	case 'accountingManager':
	case 'view_invoice':
		$xajaxUrl = $baseURL.'/'.$webDIR.'/?action=accountingManager';
		$path = ROOT_DIR.'login/accountingManager/';
		$xajax_path = ROOT_DIR.'login/xajax/';
		$page_id = 'page';
		$error_id = 'error';
		$notice_id = 'notice';
		$load_id = 'load';
		$params_id = 'params';
		$ok_msg = 'okMsg';
		$error_msg = 'errorMsg';
		$debug_id = 'debug';
		$xajaxGo = true;
		$fileTemplate = $path.'index.html';	
		$currencies = array('USD'=>'US$', 'EUR'=>'&#8364', 'GBP'=>'&pound', 'CAD'=>'CA$', 'AUD'=>'AU$');
		
		//include_once(ROOT_DIR.'rp2/global_functions.php');
		include($path.'invoice_setup.php');
		include($path.'functions.php');
		include($path.'select.conf.php');
		include($xajax_path.'accountingManager.php');

		$selector = new Select($master_db, $select_tables, $select_map, $select_delimiters, $select_additional_map, $select_aggregates);
	break;
}

// call xajax
if ($xajaxGo === true) {
	// Instantiate the xajax object.  No parameters defaults requestURI to this page, method to POST, and debug to off
	$xajax = new xajax($xajaxUrl); 
	
	//$xajax->debugOn(); // Uncomment this line to turn debugging on
	
	// Specify the PHP functions to wrap. The JavaScript wrappers will be named xajax_functionname
	foreach ($xajaxRegisterFunctions as $key => $value) {
		if (!empty($key))	{
			$xajax->registerFunction($key, $value);
		}
	}
	
	// Process any requests.  Because our requestURI is the same as our html page,
	// this must be called before any headers or HTML output have been sent
	$xajax->processRequests();
	// sve: End Xajax
}

?>